package com.ac.app.web.action.pick;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionMapping;

import com.caac.core.config.QueryClass;
import com.caac.core.util.Page;
import com.caac.core.web.action.BasePageViewAction;
import com.caac.core.web.action.PageViewForward;
import com.caac.core.web.form.BaseForm;
import com.ac.app.dm.PickSubject;
import com.ac.app.web.form.PkSubjectSearchForm;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2008</p>
 * <p>Company: AgileCentury </p>
 * @author <a href="mailto:ac@agilecentury.com">Agile</a>
 * @version 1.0
 */

public class SearchPkSubjectAction extends BasePageViewAction {
    private static final String QUERY_NAME = "pkSubjectQuery";
    private static final String ORDER_NAME = "pkSubjectOrder";
    private static final String VIEW_NAME = "pkSubjectView";

    protected PageViewForward doPageViewExecute(ActionMapping mapping,
                                                BaseForm form,
                                                HttpServletRequest request,
                                                HttpServletResponse response,
                                                int pageNo,
                                                int pageSize) throws Exception {
        PkSubjectSearchForm myForm = (PkSubjectSearchForm) form;
        QueryClass qc = getQuery(QUERY_NAME);

        Page page = new Page(getBaseManager().getCount(PickSubject.class, qc,
                myForm, myForm.isAnd()), pageNo, pageSize);
        List dmList = getBaseManager().getObjects(PickSubject.class, qc,
                myForm, myForm.isAnd(), getOrder(ORDER_NAME), page);

        return new PageViewForward(forward(mapping), dmList, page,
                getSelViewProps(VIEW_NAME), null, null);
    }

}
